# -*- coding: utf-8 -*-
"""
@Time : 2024/3/6 9:54 PM
@Author: imamhusan
@Des: 描述
"""
import socket

# ip = socket.gethostbyname('nurnabi.reqem.cn')
# print(ip)

udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)


server_address = ('192.168.1.156', 1133)

while True:
    # 发送数据
    send_mas = input('请输入发送内容：')
    udp_socket.sendto(send_mas.encode(), server_address)

    # 接收数据
    data, addr = udp_socket.recvfrom(1024)
    print(f'服务端{addr}回复内容：{data.decode()}')

    if data.decode() == 'bey':
        print('服务端已离线状态')
        udp_socket.close()
        break


